package com.cssw.fyzb.job.executor.handler;

import com.cssw.fyzb.job.executor.service.team.UserTreeService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zzf
 */
@Component
public class TeamJob extends IJobHandler {

    @Autowired
    private UserTreeService userTreeService;

    private static final Logger logger = LoggerFactory.getLogger(TeamJob.class);

    @XxlJob("teamJob")
    @Override
    public ReturnT<String> execute(String param) throws Exception {
        try {
            logger.info("Start task calculation: {} ");
            userTreeService.teamInspection();
            logger.info("Finish task calculation: {} ");
            return ReturnT.SUCCESS;
        } catch (Exception e) {
            logger.debug("", e);
            return ReturnT.FAIL;
        }
    }
}
